# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from django.urls import path,re_path
from . import views
from rest_framework.routers import DefaultRouter
from .views import BookInfoViewSet,BookInfoAuthen
from . import views

urlpatterns = [
  re_path(r'^weather/([a-z]+)/(\d{4})/$',views.weather),
  re_path(r'^q/$',views.chaxun),
  re_path(r'^p/$',views.get_body),
  re_path(r'^json/$',views.get_body_json),
  re_path(r'^index/$',views.index),
  re_path(r'^setCookie/$',views.demo_cookie),
  re_path(r'^getCookie/$',views.get_cookie),
  re_path(r'^classDemo/$',views.DemoClass.as_view(),name="classDemo"),
  re_path(r'^book_list/$',views.BooksApiView.as_view()),
  re_path(r'^book_api/(?P<pk>\d+)/$',views.BookAPIView.as_view()),
  re_path(r'^shell/$',views.shell),
  re_path(r'^shelltow/$',views.shellTwo),
  re_path(r'^demo_one/$',views.demo_shell),
  re_path(r'^demo_validate/$',views.validateField),
  re_path(r'^validate/$',views.validate),
  re_path(r'^regs/$',views.RegView.as_view()),
  re_path(r'^books/$', views.BookInfoViewSet.as_view({'get': 'list'})),
  re_path(r'^books/latest/$', views.BookInfoViewSet.as_view({'get': 'latest'})),
  re_path(r'^books/(?P<pk>\d+)/$', views.BookInfoViewSet.as_view({'get': 'retrieve'})),
  re_path(r'^books/(?P<pk>\d+)/read/$', views.BookInfoViewSet.as_view({'put': 'read'})),
  #re_path(r'^authen/$', views.BookInfoAuthen.as_view()),


]
# 可以出来视图的路由器
router = DefaultRouter()
#router.register(r'books',BookInfoViewSet)
router.register(r'authen',BookInfoAuthen)
print(router.urls)
urlpatterns += router.urls